<template>
  <div class="main-content">
    <div class="main-inner">
      <div class="main-detail" style="margin-bottom: 20px">
        <div class="m-d-select">
          <span>用户关键词：</span>
          <el-select v-model="keyword" filterable placeholder="默认全部">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
          <span class="d-select-date">日期范围：</span>
          <el-date-picker
            v-model="timeAround"
            type="daterange"
            align="right"
            unlink-panels
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions2"
            :default-value="timeDefaultShow">
          </el-date-picker>
          <el-button type="primary" icon="el-icon-search">搜索</el-button>
        </div>
      </div>
      <div class="charts-row">
        <el-row :gutter="20">
          <el-col :span="12"><div class="panel">
            <div class="panel-head"><span>热点人物</span></div>
            <div class="panel-body">
              <div class="panel-chart"></div>
            </div>
          </div></el-col>
          <el-col :span="12"><div class="panel">
            <div class="panel-head"><span>热点机构</span></div>
            <div class="panel-body">
              <div class="panel-chart"></div>
            </div>
          </div></el-col>
        </el-row>
      </div>
      <div class="charts-row">
        <el-row :gutter="20">
          <el-col :span="12"><div class="panel">
            <div class="panel-head"><span>热点来源</span></div>
            <div class="panel-body">
              <div class="panel-chart"></div>
            </div>
          </div></el-col>
          <el-col :span="12"><div class="panel">
            <div class="panel-head"><span>活跃媒体</span></div>
            <div class="panel-body">
              <div class="panel-chart"></div>
            </div>
          </div></el-col>
        </el-row>
      </div>
      <div class="charts-row">
        <el-row :gutter="20">
          <el-col :span="12"><div class="panel">
            <div class="panel-head"><span>关键词正负倾向</span></div>
            <div class="panel-body">
              <div class="panel-chart"></div>
            </div>
          </div></el-col>
          <el-col :span="12"><div class="panel">
            <div class="panel-head"><span>人物关系</span></div>
            <div class="panel-body">
              <div class="panel-chart"></div>
            </div>
          </div></el-col>
        </el-row>
      </div>
      <div class="charts-row">
       <div class="panel">
         <div class="panel-head"><span>趋势预测</span></div>
         <div class="panel-body">
           <div class="panel-chart"></div>
         </div>
       </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {mapState} from 'vuex'

  export default {
    name: "warningCharts",
    data() {
      return {
        keyword: '',
        pickerOptions2: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
        },
        timeRange: '',
        timeAround: '',
        timeDefaultShow: ''
      }
    },
    mounted() {
      this.timeDefaultShow = new Date();
      this.timeDefaultShow.setMonth(new Date().getMonth() - 1);
    },
    computed: {
      ...mapState(['options'])
    }
  }
</script>

<style scoped lang="less">
  .charts-row{
    margin: 0 20px;
    .panel{
      margin-bottom: 20px;
      background-color: #fff;
      border: 1px solid #dedede;
      border-radius: 1px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.05);
      .panel-head{
        padding: 10px 25px;
        border-bottom: 1px solid #f2f2f2;
        background-color: #fafafa;
      }
      .panel-body{
        padding: 15px 30px;
        .panel-chart{
          width: 100%;
          height: 360px;
        }
      }
    }
  }

</style>
